<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../Templates/SubFolderTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="head-title">
        <title>Edit Position | Merlion's ERP System</title>
    </ui:define>
    
    <ui:define name="content">
        
        <f:view beforePhase="#{editPositionManagerBean.initView}">
        
        <h:form>
                               
            <p:panel id="panel" header="Edit Position"> 
                <p:ajaxStatus style="width:16px;height:16px;">   
                    <f:facet name="start">   
                        <p:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" /> 
                    </f:facet> 
 
                    <f:facet name="complete">   
                        <h:outputText value="" />   
                    </f:facet>   
                </p:ajaxStatus> 
 
                <p:messages /> 
 
                <h:panelGrid columns="3" cellpadding="10"> 
                    
                    <h:outputLabel for="positionId" style="font-weight: bold" value="Position ID: " /> 
                    <h:outputLabel value="#{editPositionManagerBean.positionToEdit.id}" style="font-weight: bold" id="positionId"/> <br/>
                    
                    <h:outputLabel for="positionName" style="font-weight: bold" value="Position Name: " /> 
                    <p:inputText value="#{editPositionManagerBean.positionToEdit.description}" required="true" label="Position Name" requiredMessage="Position name is required." id="positionName"> 
                        
                    </p:inputText> 
                    <p:message for="positionName" />
                    
                </h:panelGrid>               
                
                <p:dataTable var="role" value="#{editPositionManagerBean.roles}" paginator="false" selection="#{editPositionManagerBean.selectedRoles}" style="width: 50%;" >  
                    <p:column selectionMode="multiple" />  

                    <p:column headerText="Role number">  
                        <h:outputText value="#{role.id}" />  
                    </p:column>  

                    <p:column headerText="Role Decsription">  
                        <h:outputText value="#{role.description}" />  
                    </p:column>  
                </p:dataTable>
                
                <p:commandButton id="btn" value="Update Position" update="panel" actionListener="#{editPositionManagerBean.updateExistingPosition}" ajax="true" />
            </p:panel> 
        </h:form>
            
        </f:view>
    </ui:define>

</ui:composition>
